﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace _115_按员工年龄进行降序排序_LINQ扩展方法
{
    class Program
    {
        static void Main(string[] args)
        {
            List<员工类> 列表 = new List<员工类>
            {
                new 员工类{Eid=1,Name="老高",Eage=28},
                new 员工类{Eid=2,Name="老赵",Eage=42},
                new 员工类{Eid=3,Name="老张",Eage=22},
                new 员工类{Eid=4,Name="胡强",Eage=34},
                new 员工类{Eid=5,Name="祝真",Eage=92},
                new 员工类{Eid=6,Name="宝宝",Eage=23},
            };

            //var 调出列表 = 列表.OrderByDescending(e => e.Eage);
            var 调出列表 = 列表.OrderBy(e => e.Eage);

            Console.WriteLine("将员工年龄按降序排列：");
            foreach (var item in 调出列表)
            {
                Console.WriteLine($"员工编号：{item.Eid},员工姓名：{item.Name},员工年龄：{item.Eage}");
            }
            Console.Read();

        }
    }

    //定义一个员工类
    public class 员工类
    {
        public int Eid { get; set; }
        public string Name { get; set; }
        public int Eage { get; set; }
    }
}
